<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .weui-cells {
    margin-top: 0;
  }
  .weui-cells_form {
    background: #fbfbfb;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    padding: 3px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label {
    text-align: left;
  }
  .weui_cell {
    padding: 10px 15px;
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    background: #fff;
  }
  .weui-cell_select {
    padding: 0 15px;
  }


  .weui-panel {
    background: #eee;
  }

  .rj-cont-tit {
    margin: 0;
    border-radius: 0;
  }

  .weui-panel {
    margin-top: 0;
    text-align: left;
  }

  .hd .weui-grid.js_grid {
    font-weight: 600;
  }

  .weui-grid.js_grid {
    width: 25%;
    padding: 10px 1px;
  }

  /*.weui-grid.fir {*/
  /*  width: 20%;*/
  /*}*/
  /*.weui-grid.sec {*/
  /*  width: 15%;*/
  /*}*/
  /*.weui-grid.thr {*/
  /*  width: 20%;*/
  /*}*/
  /*.weui-grid.fou {*/
  /*  width: 15%;*/
  /*}*/
  /*.weui-grid.fiv {*/
  /*  width: 15%;*/
  /*}*/

  .weui_uploader_input_wrp {
    float: left;
    position: relative;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 77px;
    height: 77px;
    border: 1px solid #D9D9D9;
  }

  .weui_uploader_hd {
    padding-top: 0;
    padding-right: 0;
    padding-left: 0;
  }

  .weui_uploader_files {
    list-style: none;
  }

  .weui_uploader_input_wrp:before {
    width: 2px;
    height: 39.5px;
  }

  .weui_uploader_input_wrp:before, .weui_uploader_input_wrp:after {
    content: " ";
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    background-color: #D9D9D9;
  }

  .weui_uploader_input {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  .weui_uploader_input_wrp:after {
    width: 39.5px;
    height: 2px;
  }

  .weui_uploader_bd {
    overflow: hidden;
  }

  .weui_cell {
    padding: 10px 15px;
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
  }

  .outstore >>> .weui-uploader_files {
    list-style: none;
    overflow-y: hidden;
  }

  .outstore >>> .weui-uploader_file {
    float: left;
    margin-right: 9px;
    margin-bottom: 9px;
    width: 79px;
    background: no-repeat 50%;
    background-size: cover;
  }

  .weui-cell.fir {
    border-top: 0;
  }

  .help {
    text-align: right;
    padding: 5px;
    font-size: 12px;
    color: #bbb;
  }

  .weui_uploader_input_wrp.inrow {
    width: 30px;
    height: 30px;
    margin: 0;
  }

  .weui_uploader_input_wrp:before {
    height: 19.5px;
  }

  .weui_uploader_input_wrp:after {
    width: 19.5px;
  }

  .weui-uploader_file.inrow {
    margin: 0;
    width: 40px;
  }

  li.weui-uploader_file {
    display: inline-block;
    padding: 3px 5px;
  }

  ul#images {
    text-align: right;
  }
  .weui-panel__bd {
    width: auto !important;
    padding: 10px 15px;
    text-align: left;
  }
  .rj-cell {
    font-size: 0.9em;
    display: inline-block;
    margin-right: 15px;
  }
  .section {
    width: auto;
    margin: 5px;
    border-radius: 5px;
    text-align: left;
    overflow: hidden;
  }
  .itemSection {
    background: #fafafa;
    margin: 3px;
  }
  .time {
    border: none;
    font-size: 16px;
    background: #fff;
  }
</style>
<template>
  <div class="examine" style="background: #eee;">
    <div class="rj-wrap" style="background: #fff;">
      {{title}}
      <a href="javascript:;" @click="$router.back(-1)" style="position: absolute; left: 10px; top: 8px">
        <img src="@/assets/back.png" style="width: 20px" />
      </a>
    </div>
    <!--    主表信息-->
    <div class="weui-form-preview section" style="background: #fff;">
      <div class="weui-form-preview__hd">
        <label class="weui-form-preview__label">编号</label>
        <em class="weui-form-preview__value">{{baseInfo.sellcode}}</em>
      </div>
      <div class="weui-form-preview__bd">
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">项目</label>
          <span class="weui-form-preview__value">{{baseInfo.projName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">申请人</label>
          <span class="weui-form-preview__value">{{baseInfo.applyname}} {{baseInfo.depname}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">销售组织</label>
          <span class="weui-form-preview__value">{{baseInfo.orgName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">货品类型</label>
          <span class="weui-form-preview__value">{{baseInfo.quitSRTypeName}}</span>
        </div>
        <div class="weui-form-preview__item" v-if="flowid == 36 && baseInfo.faretypename">
          <label class="weui-form-preview__label">物流结算</label>
          <span class="weui-form-preview__value">{{baseInfo.faretypename}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">配送方式</label>
          <span class="weui-form-preview__value">{{baseInfo.deliverytypename}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">计价方式</label>
          <span class="weui-form-preview__value">{{baseInfo.settletypename}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">结算币种</label>
          <span class="weui-form-preview__value">{{baseInfo.currencyName}}</span>
        </div>
        <div class="weui-form-preview__item">
          <label class="weui-form-preview__label">付款方式</label>
          <span class="weui-form-preview__value">{{baseInfo.paytypename}}</span>
        </div>
      </div>
    </div>
      <div class="weui-form-preview section" style="background: #fff;">
          <div class="weui-cell">
            <div class="weui-cell__hd">
              <label class="weui-label">客户</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" readonly :value="baseInfo.customername"></div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd">
              <label class="weui-label">收货城市</label>
            </div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" id='arriprovince' name="arriprovince" readonly v-model="packCitys2" placeholder="请选择收货地址" >
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd">
              <label class="weui-label">详细地址</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" type="text" name="arriaddress" placeholder=" 请输入收货详细地址" v-model="model.arriAddress"></div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd">
              <label class="weui-label">收货联系人</label></div>
            <div class="weui-cell__bd">
              <input class="weui-input" name="arricontact" v-model="model.arriContact" placeholder=" 请输入收货联系人">
            </div>
          </div>
          <div class="weui-cell">
            <div class="weui-cell__hd">
              <label class="weui-label">联系电话</label></div>
              <div class="weui-cell__bd">
                <input class="weui-input" type="number" name="arricontacttel" v-model="model.arriContactNo" placeholder=" 请输入收货人手机号">
              </div>
          </div>
      </div>
    <div class="weui-form-preview section" style="background: #fff;">
      <div class="weui-cell weui-cell_select">
        <div class="weui-cell__hd"><label class="weui-label">调度类型</label></div>
        <div class="weui-cell__bd">
          <select class="weui-select" v-model="model.settledays">
            <option value="" disabled>请选择</option>-->
            <option selected="" v-for="(item, index) in settledaysTypes" :key="item.dictValue" :value="item.dictValue">
              {{item.dictLabel}}
            </option>
          </select>
        </div>
      </div>
<!--      <div style="text-align: left;font-size: 12px;color: #bbb;padding-top: 5px;padding: 5px 15px;overflow: hidden;border-top: 0.5px solid #eee; padding-left: 0;margin-left: 15px;">-->
<!--        <p>是：当前订单分拆完成后需要继续分拆;</p>-->
<!--        <p>否：当前订单分拆完成后流程结束，不再分拆;</p>-->
<!--      </div>-->
    </div>
<!--    <div v-show="[1,2,3].includes(parseInt(model.settledays))" class="weui-form-preview section" style="background: #fff;">-->
    <div v-show="[1,2].includes(parseInt(model.settledays))" class="weui-form-preview section" style="background: #fff;">
        <div class="weui-cell fir">
          <div class="weui-cell__hd"><label class="weui-label">库存组织</label></div>
          <div class="weui-cell__bd">
            <select class="weui-select rj-line-select" name="" v-model="org" @change="(e) => {model.storeOrgId = org.id;model.storeOrgName=org.name;}">
              <option value="" disabled>请选择</option>
              <option v-for="(item, index) in orgs" :value="item">
                {{item.name}}
              </option>
            </select>
          </div>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__hd"><label class="weui-label">出库库房</label></div>
          <div class="weui-cell__bd">
            <select class="weui-select" v-model="stroom" @change="takeStrm">
              <option value="" disabled>请选择</option>
              <option v-for="(item, index) in storerooms" :key="item.guid" :value="item">
                {{item.name}}
              </option>
            </select>
          </div>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__hd">
            <label class="weui-label">发货地址</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" id='deliprovince' name="deliprovince" readonly placeholder="请选择发货地址" v-model="packCitys" >
          </div>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__hd">
            <label class="weui-label">详细地址</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="text" name="deliaddress" placeholder=" 请输入发货详细地址" v-model="model.deliAddress"></div>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__hd">
            <label class="weui-label">发货联系人</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" name="delicontact" v-model="model.deliContact" placeholder=" 请输入发货联系人">
          </div>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__hd">
            <label class="weui-label">联系电话</label></div>
          <div class="weui-cell__bd">
            <input class="weui-input" type="number" name="delicontacttel" v-model="model.deliContactNo" placeholder=" 请输入发货人手机号">
          </div>
        </div>
    </div>
    <div v-show="[2].includes(parseInt(model.settledays))" class="weui-form-preview section" style="background: #fff;">
      <div class="weui-cell">
        <div class="weui-cell__hd">
          <label class="weui-label">发货日期</label>
        </div>
        <div class="weui-cell__bd">
          <input type="text" id='datetime-picker' v-model="model.senddate" class="time" name="" readonly placeholder="请选择要求发货日期" />
        </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd">
          <label class="weui-label">到货日期</label>
        </div>
        <div class="weui-cell__bd">
          <input type="text" id='datetime-picker2' v-model="model.arrivedate" class="time" name="" readonly placeholder="请选择要求到货日期" />
        </div>
      </div>
    </div>
    <!--    明细信息-->
    <div v-if="[1].includes(parseInt(model.settledays))" class="weui-panel__bd section" style="background: #fff;" v-for="(item, index) in allItems" :key="item.guid">
      <!--      <p class="itemTit">产品明细 {{index+1}}</p>-->
      <div class="rj-cell max">
        <label>产品：</label>
        <span>{{item.productname}}</span>
        <span>{{item.spname}}</span>
      </div>
      <div v-for="(product, index) in item.sellitems" :key="product.guid" style="border-top: 1px solid #ccc;" >
        <div class="itemSection">
          <span style="display: inline-block;width: 70%;color: #333;">{{product.productname}} {{product.spname}}</span>
          <span>X</span>
          <!--          <input class="weui-input outcount" style="display: inline-block;width: 8%;" type="number" readonly :value="item.orderpack/product.orderpack" >-->
          <input class="weui-input outcount" style="display: inline-block;width: 8%;" type="number" readonly :value="item.orderpack/product.weight" >
          <span>{{product.unit}}</span>
        </div>
      </div>
      <div class="rj-cell max" v-show="showPrice">
        <label>单价：</label>
        <span>{{item.price}} {{baseInfo.settletype == 1 ? packUnit(item.unit, baseInfo.currency) : baseInfo.currency == 2 ? '美元/吨' : '元/吨'}}</span>
      </div>
      <!--      <div class="rj-cell max" v-if="baseInfo.settletype == 1">-->
      <!--        <label>订单件数：</label>-->
      <!--        <span>{{attachUnit(item.orderpack, item.unit)}}</span>-->
      <!--      </div>-->
      <!--      <div class="rj-cell max" v-if="baseInfo.settletype == 1 && item.handselcount">-->
      <!--        <label>赠送件数：</label>-->
      <!--        <span>{{attachUnit(item.handselcount, item.unit)}}</span>-->
      <!--      </div>-->
      <div class="rj-cell max">
        <label>订单数量：</label>
        <span>{{attachUnit(item.flag == 2 ? item.orderpack : item.weight, item.unit)}}</span>
      </div>
      <div class="rj-cell max" v-if="baseInfo.settletype == 1 && baseInfo.paytype < 4">
        <label>赠送数量：</label>
        <span>{{attachUnit(item.handselcount, item.unit)}}</span>
      </div>
      <div class="rj-cell">
        <label>备注信息：</label>
        <span>{{item.remark}}</span>
      </div>
    </div>

    <!--    <div v-if="[2,3].includes(parseInt(model.settledays))" class="section" v-for="(product, index) in allItems">-->
    <div v-if="[2].includes(parseInt(model.settledays))" class="section" v-for="(product, index) in allItems">
      <div class="weui-cells__title">货品明细{{index + 1}}
        <p id="acts" style="float: right;color: #1aad19;">
          <span style="padding-left: 5px;" @click="delItem(product.guid)" v-if="model.items.length > 1">删除</span>
        </p>
      </div>
      <div class="weui-cell fir" style="border-radius: 5px 5px 0 0;">
        <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" type="text" name="" readonly="true" :value="product.productname">
        </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" type="text" name="" readonly="true" :value="product.spname">
        </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">单价</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input inlinput1" type="text" name="" readonly="true" :value="product.price">
          <input class="weui-input inlinput2" type="text" readonly :value="packUnit(product.unit, currency)">
        </div>
      </div>
      <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">订单数量</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input weight" style="width: 80%;display: inline-block;" v-model="model.items[index].weight" type="number" placeholder="需进行结算的数量">
          <input class="weui-input" style="width: 15%;display: inline-block;" type="text" readonly :value="product.unit">
          <p style="text-align: left;font-size: 12px;color: #bbb;padding-top: 5px;">主订单:{{product.orderpack}}{{product.unit}}，未处理: {{product.unFinishCount}}{{product.unit}}</p>
        </div>
      </div>
      <div class="weui-cell" v-if="baseInfo.settletype == 1 && baseInfo.paytype < 4">
        <div class="weui-cell__hd"><label class="weui-label">赠送数量</label></div>
        <div class="weui-cell__bd">
          <input class="weui-input" style="width: 80%;display: inline-block;" type="number" v-model="model.items[index].handselcount" placeholder="赠送，不结算">
          <input class="weui-input" style="width: 15%;display: inline-block;" type="text" :value="product.unit">
          <p style="text-align: left;font-size: 12px;color: #bbb;padding-top: 5px;">主订单赠送数量:{{product.handselcount}}{{product.unit}}，未赠送数量: {{product.unFnsHandsCount}}{{product.unit}}</p>
        </div>
      </div>
    </div>
    <!--    动态数据-->
    <p style="height: 5px;"></p>
    <div class="weui-cells weui-cells_form section">
      <form action="" method="post" id="formid">
        <div class="weui-cell fir">
          <div class="weui-cell__hd"><label class="weui-label">附件上传</label></div>
          <div class="weui-cell__ft">
            <div class="weui_uploader_bd">
              <ul class="weui_uploader_files"></ul>
              <div class="weui_uploader_input_wrp inrow">
                <UploadFile3 class="weui_uploader_input" v-on:pushfile="setFile"></UploadFile3>
              </div>
            </div>
          </div>
          <ul class="weui-uploader_files" id="images">
            <li class="weui-uploader_file" v-for="(fil, index) in filenames" @click=delFile(fil,fileids[index])>
              {{fil}}
            </li>
          </ul>
        </div>
        <div class="weui-cell">
          <div class="weui-cell__bd">
            <textarea class="weui-textarea opinion" id="opinion" v-model="opinion" name="opinion" placeholder="请输入意见内容" rows="2"></textarea>
          </div>
        </div>
      </form>
    </div>
    <div id="bmlogs">
      <SalesOperationLogs7 :nodeid="nodeid" :orderid="id" :srguid="''" :departid="baseInfo.depguid" :flowid="flowid"></SalesOperationLogs7>
    </div>
    <ApproveBom v-if="isReady" type="sellSplit" :flowid="flowid" :nodeid="nodeid" :id="id" :srguid="baseInfo.srguid" :departid="baseInfo.depguid" :model="model" :opinion="opinion" :fileids="fileids" :refuseflag="refuseflag" :annex="annex" passUrl="/prod-api/bill/sellform/partOrDispatch" refuseUrl="/prod-api/bill/sellform/refuse"  :navgateUrl="`/sellform2/SellformList?flowid=${flowid}`" ></ApproveBom>
  </div>
</template>

<script>
  import wx from 'weixin-js-sdk';
  import SalesOperationLogs7 from '@/components/common/SalesOperationLogs7'
  import ApproveBom from '@/components/common/ApproveBom'
  import UploadFile3 from "../common/UploadFile3";

  export default {
    name: 'SplitOrder',
    data () {
      return {
        flowid: 34,
        opinion: '',
        openid: localStorage.openid,
        id: '',
        title: '',
        nodeid: '',
        annex: '',
        baseInfo: {},
        wxParams: {},
        images: {
          serverId: [],
          srcStr: [],
        },
        refuseflag: '',
        refuseNodes: [],
        orderfiles: [],
        isReady: false,
        filenames: [],
        fileids: [],
        titleName:"",
        model: {
          settledays: '',
          items: []
        },
        orgs: [],
        org: '',
        storerooms: [],
        stroom: '',
        packCitys: '',
        packCitys2: '',
        itemsCount: '',
        handsCount: '',
        sellitems: [],
        allItems: [],
        settledaysTypes: [],
        showPrice: false,
      }
    },
    components: {
      SalesOperationLogs7,
      ApproveBom,
      UploadFile3
    },
    computed: {
      pageTitle: function () {
        let tit = '销售订单';
        switch (this.flowid) {
          case '34':
            tit = '电商订单';
            break;
          case '35':
            tit = '样品订单';
            break;
          default:
            tit = '销售订单';
            break;
        }
        return tit;
      }
    },
    created() {
      if (this.$route.query.flowid) this.flowid = this.$route.query.flowid;
      //页面title设置
      document.title = '土豆集-' + this.pageTitle;
    },
    async mounted () {
      let that = this;

        //日历初始化
        $("#datetime-picker").calendar({
          dateFormat: 'yyyy-mm-dd'
        });
        $("#datetime-picker").change(function () {
          that.model.senddate = $(this).val().replace(/\//g, '-');
        })
        $("#datetime-picker2").calendar({
          dateFormat: 'yyyy-mm-dd'
        });
        $("#datetime-picker2").change(function () {
          that.model.arrivedate = $(this).val().replace(/\//g, '-');
        })

      $("#arriprovince").cityPicker();
      $("#arriprovince").change(function () {
        let addr = $(this).val().split(' ');
        that.packCitys2 = addr;
        that.model.arriProvince = addr[0];
        that.model.arriCity = addr[1];
        that.model.arriDistrict = addr[2];
      })
      $("#deliprovince").cityPicker({
        title: "请选择发货地址",
      });
      $("#deliprovince").change(function () {
        let addr = $(this).val().split(' ');
        that.model.deliProvince = addr[0];
        that.model.deliCity = addr[1];
        that.model.deliDistrict = addr[2];
      })

      //提交操作定位到页面底部
      //$('#bmlogs').css('margin-bottom', this.$refs.actHtml.offsetHeight)

      //$('#opinion').focus();
      this.id = this.$route.query.id;
      this.nodeid = this.$route.query.nodeid;
      this.annex = this.$route.query.annex;
      this.title = this.$route.query.title;
      this.model.partitiontype = this.$route.query.partitiontype;
      this.refuseflag = this.$route.query.refuseflag;
      this.getOrgs();
      await this.getBaseInfo(this.id);
      this.getDispathTypes();

      if (this.$route.query.status) {
        this.status = this.$route.query.status;
      }
      //获取是否显示价格权限
      this.getPricePermis();
    },
    watch: {
      'model.settledays': function(val) {
        console.log('[2].includes(parseInt(val)):', [2].includes(parseInt(val)))
        this.$forceUpdate();
      },
      org: function (val) {
        this.getSr(val.guid);
      },
    },
    methods: {
      getPricePermis: function() {
        let that = this;
        this.axios({
          method: 'get',
          url: '/prod-api/flow/flowtemp/showPrice',
          params: {id: this.flowid}
        }).then(response => {
          if (response.data.code == 200) {
            that.showPrice = response.data.msg == 1;
          } else {
            //失败时不提示
          }
        });
      },
      //物流结算
      getDispathTypes: function () {
        let that = this;
        this.axios({
          method: 'get',
          url: '/prod-api/system/dict/data/type/sellform_settledays',
        }).then(response => {
          if (response.data.code == 200) {
            that.settledaysTypes = response.data.data.filter(item => {
              if (this.baseInfo.partitionflag == 1) {
                return item.dictValue == 1 || item.dictValue == 2;
              } else if (this.baseInfo.partitionflag == 2) {
                return item.dictValue == 2 || item.dictValue == 3 || item.dictValue == 4;
              }
            });
            this.settledays = response.data.data[0].dictValue;
          } else {
            this.toastText('获取调度类型数据失败');
          }
        });
      },
      takeStrm() {
        this.model.storermguid = this.stroom.guid;
        this.model.strmId = this.stroom.id;
        this.model.storeroomname=this.stroom.name;
        this.packCitys = this.stroom.province + ' ' + this.stroom.city + ' ' + this.stroom.area;
        this.model.deliProvince = this.stroom.province;
        this.model.deliCity = this.stroom.city;
        this.model.deliDistrict = this.stroom.area;
        this.model.deliAddress=this.stroom.address;
        this.model.deliContact=this.stroom.contact;
        this.model.deliContactNo=this.stroom.contacttel;
      },
      delItem: function (id) {
        let that = this;
        $.confirm('确定要删除？', function () {
          that.allItems = that.allItems.filter(item => item.guid != id);
          that.model.items = that.model.items.filter(item => item.guid != id);
        })
      },
      packUnit: function(unit, currency) {
        return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
      },
      getOrgs: function() {
        this.axios({
          method: 'get',
          url: '/prod-api/getOrgs',
        }).then(response => {
          if (response.data.code == 200) {
            this.orgs = response.data.data;
          } else {
            this.toastText('获取组织数据失败')
          }
        });
      },
      getSr: function(orgId) {
        this.axios({
          method: 'get',
          url: '/prod-api/getStoreRoomByOrgIdOrPermissions',
          params: {guid: orgId, enable: 1}
        }).then(response => {
          if (response.data.code == 200) {
            this.storerooms = response.data.data;
          } else {
            this.toastText('获取库房数据失败');
          }
        });
      },
      delFile: function (name, id) {
        let that = this;
        $.confirm('确定要删除？', function () {
          that.axios({
            method: 'post',
            url: '/prod-api/common/delete',
            params: {id: id}
          })
          that.fileids = that.fileids.filter(item => {
            return item != id;
          })
          that.filenames = that.filenames.filter(item => {
            return item != name;
          })
        })
      },
      setFile: function (file) {
        this.filenames.push(file.name);
        this.fileids.push(file.id);
      },
      packUnit: function(unit, currency) {
        return unit != undefined && unit != '' ? currency == 2 ? '美元/' + unit : '元/' + unit : '';
      },
      getBaseInfo: async function (id) {
        await this.axios({
          method: 'get',
          url: `/prod-api/bill/sellform/review`,
          params: {orderid: id, partitiontype: this.model.partitiontype}
        }).then(response => {
          if (response.data.code == 200) {
            let data = response.data;
            this.baseInfo = data.form || {};
            this.itemsCount = response.data.itemsCount;
            this.handsCount = response.data.handsitems;
            this.sellitems = this.baseInfo.items;
            let allItems = data.spitems ? data.spitems.concat(this.baseInfo.items) : this.baseInfo.items;
            this.allItems = allItems.map(item => {
              if (item.speguid) {
                item.unFinishCount = this.itemsCount[item.speguid];
                item.unFnsHandsCount = this.handsCount[item.speguid];
                item.type = 'spitem';
              } else if (item.spguid) {
                item.unFinishCount = this.itemsCount[item.spguid];
                item.unFnsHandsCount = this.handsCount[item.spguid];
                item.type = 'item';
              }
              return item;
            })
            console.log('this.allItems:', this.allItems)
            if (this.baseInfo.arriProvince) {
              this.packCitys2 = this.baseInfo.arriProvince + ' ' + this.baseInfo.arriCity + ' ' + this.baseInfo.arriDistrict;
            }
            this.model.id = this.baseInfo.id;
            this.model.settletype = this.baseInfo.settletype;
            // if ([1,2].includes(parseInt(this.baseInfo.partitionflag))) {
              this.model.arriProvince = this.baseInfo.arriProvince;
              this.model.arriCity = this.baseInfo.arriCity;
              this.model.arriDistrict = this.baseInfo.arriDistrict;
              this.model.arriAddress = this.baseInfo.arriAddress;
              this.model.arriContact = this.baseInfo.arriContact;
              this.model.arriContactNo = this.baseInfo.arriContactNo;
              this.model.senddate = this.baseInfo.senddate;
              this.model.arrivedate = this.baseInfo.arrivedate;
            // }
            // if (this.baseInfo.partitionflag == 2) {
              this.model.items = this.allItems.map(item => {
                let nitem = {};
                nitem.guid = item.guid;
                nitem.type = item.type;
                // nitem.orderpack = '';
                // nitem.handselcount = '';
                nitem.weight = '';
                nitem.handselcount = '';
                nitem.unFinishCount = item.unFinishCount;
                nitem.unFnsHandsCount = item.unFnsHandsCount;
                return nitem;
              })
            console.log('this.model:', this.model)
            // }
          } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
            //不不设置提示
          } else {
            this.toastError('系统错误');
          }
          this.isReady = true;
        });
      },

    }
  }
</script>
